/**
 * 
 */
package com.java.test.datacenter.dto;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

import org.springframework.jdbc.core.RowMapper;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author 出款统计明细
 *
 */
public class PaymentInfo implements RowMapper<PaymentInfo> {

	// 用户ID 出款人id
	private int userId;

	// 出款人名称
	private String userName;

	// 出款总笔数
	private int count;

	// 总计金额
	private double amount;

	// 最新一笔出款时间
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime newOutTime;

	// 待汇款id
	private int remitId;

	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime startTime;

	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime endTime;

	public LocalDateTime getStartTime() {
		return startTime;
	}

	public void setStartTime(LocalDateTime startTime) {
		this.startTime = startTime;
	}

	public LocalDateTime getEndTime() {
		return endTime;
	}

	public void setEndTime(LocalDateTime endTime) {
		this.endTime = endTime;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public LocalDateTime getNewOutTime() {
		return newOutTime;
	}

	public void setNewOutTime(LocalDateTime newOutTime) {
		this.newOutTime = newOutTime;
	}

	public int getRemitId() {
		return remitId;
	}

	public void setRemitId(int remitId) {
		this.remitId = remitId;
	}

	@Override
	public PaymentInfo mapRow(ResultSet rs, int rowNum) throws SQLException {

		PaymentInfo info = new PaymentInfo();

		info.setAmount(rs.getDouble("amount"));

		info.setNewOutTime(rs.getTimestamp("new_out_time").toInstant().atZone(ZoneOffset.ofHours(8)).toLocalDateTime());

		info.setRemitId(rs.getInt("remit_id"));

		info.setUserId(rs.getInt("user_id"));

		info.setUserName(rs.getString("user_name"));

		info.setCount(rs.getInt("count"));

		return info;
	}

}
